{include file="entete.tpl"}
{literal}
<script type="text/javascript" src= "/PariGest/pages/js/prototype.js"></script>
<script type="text/javascript" src= "/PariGest/pages/js/outilsAjax.js"></script>
<script type="text/javascript">
function init()
{
  ajouteCtrl({input:{/literal}$("Date"){literal}, ctrl: "DATE", oblig: true, message: "Date"});
  ajouteCtrl({input:{/literal}$("Mise"){literal}, ctrl: "FLOAT", oblig: true, message: "Mise", min:{/literal}{$MiseMini}{literal}});
  ajouteCtrl({input:{/literal}$("Cote"){literal}, ctrl: "FLOAT", oblig: true, message: "Cote", minsup:1});
  ajouteCtrl({input:{/literal}$("NbParis"){literal}, ctrl: "INT", oblig: true, message: "Nb de Paris", min:1});
  calculeMiseConseillee(); 
}

function changeMise()
{
  calculeMiseConseillee();
  calculeGainsPossibles();
}

function changeCote(input)
{
  if( !verifCtrl(input) ) return ;
  calculeMiseConseillee();
  calculeGainsPossibles();
}

function calculeMiseConseillee()
{
  var url = "xmlSelectMiseConseillee.php";
  var parametres = "IdCompte="+$F("idCompte");
  parametres    += "&Cote="+($F("Cote")=="Cote"?"":$F("Cote"));
  lanceRequest(url, parametres, majMiseConseillee);
}

function majMiseConseillee(transport)
{
  //alert('majMiseConseillee('+transport+')');
  $("MiseConseillee").value = litNoeud(transport.responseXML, "MiseConseillee");
}

function calculeGainsPossibles()
{ 
  if( $F("Mise") == "" || $F("Mise") == "Mise" || $F("Cote") == "" || $F("Cote") == "Cote" )
  {
    $("GainsPossibles").value = "";
    return;
  }
  var gainsPossible = parseFloat($F("Mise")) * parseFloat($F("Cote"));
  var iGainsPossible = parseInt(Math.round(100 * gainsPossible));
  gainsPossible = parseFloat(iGainsPossible/100);
  $("GainsPossibles").value = gainsPossible;
  
  if( parseFloat($F("Mise")) < parseFloat($F("MiseConseillee")) ) 
  {
    $("GainsPossibles").addClassName("rouge");
  }
  else if( parseFloat($F("Mise")) > parseFloat($F("MiseConseillee")) )  
  {
    $("GainsPossibles").addClassName("vert");
  }
  else
  {
    $("GainsPossibles").removeClassName("rouge");
    $("GainsPossibles").removeClassName("vert");
  }
}

/*function validerSpecif()
{
  if( !verifAllCtrl() ) return;
  if( parseFloat($F("Cote")) <= 1 )
  {
    top.afficheMsg( { titre : 'Cote incorrecte !', message : 'La cote doit être supérieur à 1€' });
    return false;
  }   
  if( parseInt($F("NbParis")) < 1 )
  {
    top.afficheMsg( { titre : 'Nb de paris est incorrect !', message : 'Le nombre de paris doit être supérieur à 0' });
    return false;
  }    
  return true;
}*/
</script>
{/literal}
<html>
  <body onload="init();">
    <form action="jeux.php" method="post">
    
      {include file="IncSelectCompte.tpl"}
        
      <input type="hidden" name="Action" id="Action" value="">
      <table border=0 cellspacing=5 cellpadding=0 class=lib>	
        <tr>
          <td>
            {html_options name=LstSports options=$LstSports selected=$IndSportSelected}
          </td>
          <td>le&nbsp;<input type="text" name="Date" id="Date" size="10" onChange="verifCtrl(this)" value="{$DateDuJour|date_format:"%d/%m/%Y"}"></td>
          <td><input type="text" size=4 name="Mise" id="Mise" value="Mise" onChange="changeMise();verifCtrl(this)" onFocus="if(this.value == 'Mise') this.value = ''" onBlur="if(this.value == '') this.value = 'Mise'"></td>
          <td>x</td>
          <td><input type="text" size=4 name="Cote" id="Cote" value="{$CoteDefaut}" onChange="changeCote(this);" onFocus="if(this.value == 'Cote') this.value = ''" onBlur="if(this.value == '') this.value = 'Cote'"></td>
          <td>=</td>
          <td><input type="text" size=4 id="GainsPossibles" value="" class="lect" tabIndex=-1 readOnly></td>
          <td>Combiné&nbsp;<select id="IndCombine" name="IndCombine"><option value="N" selected>Non</option><option value="O">Oui</option></select></td>
          <td>Nb&nbsp;paris&nbsp;<input type="text" size=1 name="NbParis" id="NbParis" onChange="verifCtrl(this)" value="1"></td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td colspan=5 class="petit">Mise conseillée : <input class="lect" tabIndex=-1 readOnly type=text id="MiseConseillee" size=4 value=""></td>          
        </tr>
      </table>
    </form>
  </body>
</html>